import axios from 'axios';
import {getCookie} from './cookie';

const service = axios.create({
    // baseURL: /^jasonandjay.com$/.test(window.location.host)?'//easymarket.jasonandjay.com/':'//easymarket.jasonandjay.com/',
    baseURL:process.env.NODE_ENV === 'production' ? '//easymarket.jasonandjay.com/' : 'http://127.0.0.1:8888',
    timeout:5000
})

service.interceptors.request.use(function(config){
    config.headers['x-nideshop-token'] = getCookie()
    return config
},function(error){
    return Promise.reject(error)
})

service.interceptors.response.use(function(response){

    return response.data
},function(error){
    return Promise.reject(error)
})

export default service